package com.fsy.Controller;

import com.fsy.entities.Askers;
import com.fsy.entities.Modules;
import com.fsy.service.AskersService;
import com.fsy.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/askers")
public class AskersController {

    @Resource
    private AskersService askersService;

    @GetMapping("findAskers")
    public Map<String,Object> findAskers(Askers askers){
        List<Askers> askersList = askersService.findAllAskers(askers);
        int count = askersService.selectCounts(askers);
        return Result.toClient("0", "",count,askersList);
    }

    @PostMapping("/updateAskers")
    public Map<String,Object> updateAskers(@ModelAttribute Askers askers){
        Boolean rel = askersService.updateById(askers);
        Map<String,Object> rslmap = new HashMap<>();
        if (rel){
            rslmap.put("code","0");
            rslmap.put("msg","修改权重成功");
        }else{
            rslmap.put("code","1");
            rslmap.put("msg","修改权重失败");
        }
        return rslmap;
    }

}
